angular.module('service.host', [])
    .factory('hostService', function ($http) {
        return {
            get: function(page,pagesize,hostnamesearch ,callback){
                $http({

                    url : '/resource/host',
                    method : 'GET',
                     params:{"command":"listVirtualMachines",
                    	 "page":page==null?1:page,
                    	 "pagesize":pagesize,
                    	 "keyword":hostnamesearch
                    	 }
                }).then(function(response) {
                    callback(response.data);
                });
            },
            post: function (formBean, callback) {
                $http({
                    url: '/resource/host',
                    method: 'POST',
                    params: formBean
                }).then(function (response) {
                    callback(response.data);
                });
            },
            template: function (callback) {
                $http({
                    url: 'resource/deploy/templates',
                    method: 'GET',
                }).then(function (response) {
                    callback(response.data)
                })
            },
            networks: function (callback) {
                $http({
                    url: "resource/deploy/listNetworks",
                    params: {"command": "listNetworks"},
                    method: "GET"
                }).then(function (response) {
                    callback(response.data)
                })
            }
        }
    });
